/* 执行终端命令 */

// 开启进程
const { exec, spawn } = require("child_process");

// 执行终端命令
const commandSpawn = (...args) => {
  const childProcess = spawn(...args);
  // 将输出流和错误流放进主进程
  childProcess.stdout.pipe(process.stdout);
  childProcess.stderr.pipe(process.stderr);
  return new Promise((resolve, reject) => {
    childProcess.on("close", () => {
      resolve();
    });
  });
};

module.exports = {
  commandSpawn,
};
